<template>
    <div class="list">
    <el-row class="head">
        <el-col >——维修区域列表/维修列表</el-col>
    </el-row>
        <el-row class="title">
            <el-col>维修区域列表</el-col>
        </el-row>
        <el-form  :model="form" label-width="100px" class="formrule">
            <el-form-item label="一级区域">
                <el-select v-model="form.firstlocation" placeholder="全部">
                    <el-option
                            v-for="item in firsts"
                            :key="item.first"
                            :label="item.first"
                            :value="item.first"
                    >
                    </el-option>
                </el-select>
            </el-form-item>

            <el-form-item>
                <el-button type="primary" @click="onSubmit(form)">查询</el-button>
            </el-form-item>
        </el-form>


        <el-table
                :data="locations"
                border
                style="width: auto">
            <el-table-column
                    prop="first"
                    label="一级区域"
                    width="680">
            </el-table-column>
            <el-table-column
                    prop="second"
                    label="二级区域"
                    width="665">
            </el-table-column>



        </el-table>
    </div>
</template>

<script>
    export default {
        name: "list",
        data(){
            return{
                form: {
                    firstlocation: '',
                },
                locations:[],
                firsts:[],
            }
        },
        created() {
            this.$axios.post("/api/v1/user/getlocation").then(result => {

                return result.data;
            })
                .then(data1 => {
                    console.log(data1);
                    this.locations = data1;
                });
            this.$axios.post("/api/v1/user/seldistinctfirst").then(result => {

                return result.data;
            })
                .then(data1 => {

                    this.firsts=data1.data;
                });
        },
        methods:{
            onSubmit(form){
                this.$axios.post("/api/v1/user/seltypeandlocation",form).then(result => {

                    return result.data;
                })
                    .then(data1 => {
                        console.log(data1);
                        this.locations = data1;
                    });
            }
        }
    }
</script>

<style scoped>
    .el-input{
        width: 600px;
    }
</style>